
<!DOCTYPE html>
<html>
<!--
	作者：github.com/WangEn
	时间：2018-02-02
	描述：添加文章类别
-->

<head>
  <meta charset="UTF-8">
  <title>添加新闻</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../static/css/font.css">
  <link rel="stylesheet" href="../../static/css/weadmin.css">
</head>

<body>
  <div class="weadmin-body">
     <form class="layui-form" lay-filter="formModel" id="addForm">
      <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: red;">*</span>新闻标题</label>
        <div class="layui-input-inline">
          <input type="text" name="newstypename" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
      </div>
    
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit="" lay-filter="add">立即提交</button>
        </div>
      </div>
    </form>
    
    
    
  </div>
  <script src="../../lib/layui/layui.js" type="text/javascript"></script>
 
</body>

<script>
layui.use(['laydate','layer','form','table','tree','upload','transfer'], function() {
	var laydate = layui.laydate	//日期组件
		,layer = layui.layer	//弹层组件
		,form = layui.form		//表单组件
		,upload = layui.upload  //上传组件
		,tree = layui.tree		//树形结构组件
		,$= layui.jquery    	//jQuery
		,table = layui.table	//表格组件
		,transfer = layui.transfer; //穿梭框组件

		laydate.render({
			elem:'#newstime'
		});
  

  //监听提交
  form.on('submit(add)', function (data) {

	  $.ajax({
			type: 'post', 					//提交方式get或post
			url: '../../../admin/newstype?reqName=insert',	 					//提交路径
			data: $("#addForm").serialize(), //参数
			dataType: 'json', 				//返回的数据类型
			success: function(res) { 		//提交成功
				
				 layer.alert(res.msg, {
		              icon: 6
		            }, function () {
		            	//先得到当前iframe层的索引
		            	var index = parent.layer.getFrameIndex(window.name); 
		            	//再执行关闭 
		            	parent.layer.close(index);  
		            	//刷新父级页面的表格
		            	parent.layui.table.reload('proTable',{page:{curr:1}});
		            });
			},
			error: function() { //提交失败
				alert("系统异常！！")
			}
		}); 

    return false;
  });


});


</script>


</html>